import request from "@/utils/request.js";

/**
 * 分组列表
 * @return GroupItem[]
 */
export const formGroupList = () => {
  return request({
    url: "/dbo/formTemplate/leftMenuList",
    method: "get"
  });
};

/**
 * 添加分组
 * @param { GroupItem } data
 */
export const addGroup = data => {
  return request({
    url: "/dbo/formTemplate/add",
    method: "post",
    data
  });
};

/**
 * 编辑分组
 * @param { GroupItem } data
 */
export const editGroup = data => {
  return request({
    url: `/dbo/formTemplate/update/${data.formId}`,
    method: "put",
    data
  });
};

/**
 * 分组排序
 * @param { GroupItem[] } data
 */
export const sortGroup = data => {
  return request({
    url: "/dbo/formTemplate/updateSort",
    method: "put",
    data
  });
};

/**
 * 删除分组
 */
export const deleteGroup = formId => {
  return request({
    url: `/dbo/formTemplate/delete/${formId}`,
    method: "post"
  });
};

/**
 * 复制分组
 */
export const copyGroup = formId => {
  return request({
    url: `/dbo/formTemplate/copyDboDesingerFormTemplate/${formId}/${copyFormId}}`,
    method: "post"
  });
};

/**
 * 新增设计师需求表单字段模板
 * @param {Object} data
 * @param { string } data.formId
 * @param { string } data.props
 */
export const addFormTemplate = data => {
  return request({
    url: "/dbo/formTemplate/addDboDesingerFormTemplate",
    method: "post",
    data
  });
};

/**
 * formId查询组件列表
 */
export const formItemsByFormId = formId => {
  return request({
    url: `/dbo/formTemplate/componentLibraryList/${formId}`,
    method: "get"
  });
};
